#include "mcu_config_uart.h"
#include <stdio.h>
void uart_init()
{
    USART_InitTypeDef USART_InitStructure;
    USART_InitStructure.USART_BaudRate = 115200;
    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
    USART_InitStructure.USART_StopBits = USART_StopBits_1;
    USART_InitStructure.USART_Parity = USART_Parity_No;
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
    USART_Init(USART1, &USART_InitStructure);

    USART_Cmd(USART1, ENABLE);
}

void uart_send_byte(uint8_t byte)
{
    while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
    USART_SendData(USART1, byte);
}

void uart_send_u16(uint16_t num)
{
    uint8_t byte1 = (num >> 8) & 0xFF;
    uint8_t byte2 = num & 0xFF;
    uart_send_byte(byte1);
}

void uart_send_string(char *str,uint8_t len)
{
    uint8_t i;
    for(i=0;i<len;i++)
    {
        uart_send_byte(str[i]);
    }
}







